For inserting a DLL for tracing see
http://www.wheaty.net/FAQ.htm#APISPY32 I altered it a bit to allow intercepting DLLs called by other DLLs.
As for your contacts sync problem this looks like it should work
Make sure you set the path correctly to the contacts - at least in my Notes setup they are in a separate database file c:\Notes\Data\names.nsf